<?php
namespace Admin\Controller;

class OrderController extends AdminController
{
    public function index()
    {
    $res=D('Order')->field('shop_order.*,shop_sname.title')->join('shop_sname ON shop_order.sid = shop_sname.id')->select();
    $this->assign('res',$res);
    $this->display();
    }

    public function ad()
    {
    $res=D('Order')->field('shop_order.*,shop_sname.title')->join('shop_sname ON shop_order.sid = shop_sname.id')->where(array('shop_order.status'=>1))->select();
    $this->assign('res',$res);
    $this->display();
    }

    public function ninput()
    {
    $res=D('Order')->field('shop_order.*,shop_sname.title')->join('shop_sname ON shop_order.sid = shop_sname.id')->where(array('shop_order.status'=>0))->select();
    $this->assign('res',$res);
    $this->display();
    }
    public function changeStatus($method=null){
        $id = array_unique((array)I('id',0));
        if( in_array(C('USER_ADMINISTRATOR'), $id)){
            $this->error("不允许对超级管理员执行该操作!");
        }
        $id = is_array($id) ? implode(',',$id) : $id;
        if ( empty($id) ) {
            $this->error('请选择要操作的数据!');
        }
        $map['id'] =   array('in',$id);
        switch ( strtolower($method) ){
            case 'forbiduser':
                $this->forbid('Order', $map );
                break;
            case 'resumeuser':
                $this->resume('Order', $map );
                break;
            case 'deleteuser':
                $this->delete('Order', $map );
                break;
            default:
                $this->error('参数非法');
        }
    }
}